package Integrity;

import java.io.Serializable;

import Global.ConstantVariable;
import Global.ConstantVariable.DefaultFileNamesConstants;
import Global.DirectoryStructureAndSettingsClass;
import Global.GlobalClass;
import Utility.FileUtilityClass;

public class IntegrityCheckerClass implements Serializable{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 2001580760595194866L;
	private IntegrityDataClass IntegrityControlData;
	
	public IntegrityCheckerClass()
	{
		IntegrityControlData = new IntegrityDataClass();
	}

	public void setIntegrityControlData(IntegrityDataClass integrityControlData) {
		IntegrityControlData = integrityControlData;
	}

	public IntegrityDataClass getIntegrityControlData() {
		return IntegrityControlData;
	}
	
	public boolean equals(IntegrityCheckerClass otherIntegrityChecker)
	{
		if(IntegrityControlData.equals(otherIntegrityChecker.getIntegrityControlData()))					
				return true;
		
		return false;
	}
	
	public static boolean checkIfItIsNecessaryToRecalculateShortestPaths(int edgeType)
	{		
		if(GlobalClass.RunningValues.integrityCheckResult)
		{
			String fileNameForShortestPathObjectFile = getFileNameForShortestPathObject(edgeType);
			
			System.out.println("fileNameForShortestPathObjectFile:"+fileNameForShortestPathObjectFile);
			
			if(FileUtilityClass.checkIfFileExists(fileNameForShortestPathObjectFile))
			{				
				return false;
			}
			else
				return true;
		}	
		else
			return true;
	}
	
	public static String getFileNameForIntgerityCheckObject()
	{
		String fileNameForThePreviousIntegrityCheckFile = DirectoryStructureAndSettingsClass.getFullPathOfTheStaticRootDirectoryNameForTheCurrentDataset()
		+ConstantVariable.DefaultDirectoryNamesConstants.DirectoriesUnderStaticDatasetDirectory.INTEGRITY_RELATED_TO_DATASET_FOLDER_NAME+DefaultFileNamesConstants.IntegrityCheckFiles.INPUT_FILES_INTEGRITY_CHECK_PREV_OBJECT_FILENAME +ConstantVariable.DefaultDirectoryNamesConstants.FileExtensions.BACKUP_FILE_FORMAT_EXTENSION;
		return fileNameForThePreviousIntegrityCheckFile;
	}
	
	public static String getFileNameForShortestPathObject(int edgeType)
	{
		String similarityStr = "";
		
		String fileNameForThePreviousIntegrityCheckFile = DirectoryStructureAndSettingsClass.getFullPathOfTheStaticRootDirectoryNameForTheCurrentDataset()
		+ConstantVariable.DefaultDirectoryNamesConstants.DirectoriesUnderStaticDatasetDirectory.BACKUP_RELATED_TO_DATASET_FOLDER_NAME;
		
		if(edgeType==ConstantVariable.Common_ConstantVariables.DEFAULT_EDGE_TYPE_FOR_CONTENT_GRAPH)
			similarityStr = ConstantVariable.SimilarityCalculator_ConstantVariables.DEFAULT_SIMILARITY_MEASURE;
		
		fileNameForThePreviousIntegrityCheckFile += (edgeType + ConstantVariable.Format_ConstantVariables.DASH_CHAR+similarityStr+DefaultFileNamesConstants.IntegrityCheckFiles.SHORTEST_PATH_OBJECT_FILENAME+ConstantVariable.DefaultDirectoryNamesConstants.FileExtensions.BACKUP_FILE_FORMAT_EXTENSION);
		
		//System.out.println("fileNameForThePreviousIntegrityCheckFile:"+fileNameForThePreviousIntegrityCheckFile);
			
		return fileNameForThePreviousIntegrityCheckFile;
	}
	
	public static String getFileNameForSimilarityForContentObject()
	{
		String fileNameForThePreviousIntegrityCheckFile = DirectoryStructureAndSettingsClass.getFullPathOfTheStaticRootDirectoryNameForTheCurrentDataset()
		+ConstantVariable.DefaultDirectoryNamesConstants.DirectoriesUnderStaticDatasetDirectory.BACKUP_RELATED_TO_DATASET_FOLDER_NAME
		+DefaultFileNamesConstants.IntegrityCheckFiles.SIMILARITY_FOR_CONTENT_OBJECT_FILENAME+ConstantVariable.SimilarityCalculator_ConstantVariables.DEFAULT_SIMILARITY_MEASURE+ConstantVariable.DefaultDirectoryNamesConstants.FileExtensions.BACKUP_FILE_FORMAT_EXTENSION;
		
		System.out.println("fileNameForThePreviousIntegrityCheckFile:"+fileNameForThePreviousIntegrityCheckFile);
		return fileNameForThePreviousIntegrityCheckFile;
	}
	
	public static String getFileNameForPrevMetaClsExecutionResultsObject()
	{
		String fileNameForThePreviousIntegrityCheckFile = DirectoryStructureAndSettingsClass.getFullPathOfTheStaticRootDirectoryNameForTheCurrentDataset()
		+ConstantVariable.DefaultDirectoryNamesConstants.DirectoriesUnderStaticDatasetDirectory.BACKUP_RELATED_TO_DATASET_FOLDER_NAME
		+DefaultFileNamesConstants.IntegrityCheckFiles.PREV_META_CLS_EXECUTION_RESULTS_OBJECT_FILENAME+ConstantVariable.SimilarityCalculator_ConstantVariables.DEFAULT_SIMILARITY_MEASURE+ConstantVariable.ExecutionParameters.SELECTED_SECOND_LEVEL_LOCAL_CLASSIFIER_FOR_MERGE_CALCULATION_LINK + ConstantVariable.ExecutionParameters.SELECTED_SECOND_LEVEL_LOCAL_CLASSIFIER_FOR_MERGE_CALCULATION_CONTENT+ConstantVariable.DefaultDirectoryNamesConstants.FileExtensions.BACKUP_FILE_FORMAT_EXTENSION;
		
		System.out.println("fileNameForThePreviousMetaResultsFile:"+fileNameForThePreviousIntegrityCheckFile);
		return fileNameForThePreviousIntegrityCheckFile;
	}
}
